//左叶子之和
class Solution {
public:
    int sumOfLeftLeaves(TreeNode* root) 
    {
        if(!root) return 0; 
        int value=0;
        if(root->left && !root->left->left && !root->left->right)
        {
            value+=root->left->val;
        }
        int left=sumOfLeftLeaves(root->left);
        int right=sumOfLeftLeaves(root->right);
        return value+left+right;
    }
};
//找树左下角的值
class Solution {
public:
    int findBottomLeftValue(TreeNode* root) 
    {
        int res=root->val;
        int maxdeep=0;
        dfs(root,0,maxdeep,res);
        return res;
    }
    void dfs(TreeNode* root,int deepth,int& maxdeep,int& res)
    {
        if(!root->left && !root->right)
        {
            if(deepth>maxdeep)
            {
                maxdeep=deepth;
                res=root->val;
            }
            return;
        }
        if(root->left)
        {
            dfs(root->left,deepth+1,maxdeep,res);
        }
        if(root->right)
        {
            dfs(root->right,deepth+1,maxdeep,res);
        }
        return;
    }
};